package num1021;

/**
 * @author : DuJiabao
 * @Project : sword-finger-offer
 * @Time : 2021/5/8 20:28
 * @Desc :
 */
public class Solution {
  public String removeOuterParentheses(String S) {
    StringBuilder res = new StringBuilder();
    int level = 0;
    for (char c : S.toCharArray()) {
      if (c == ')') level--;
      if (level >= 1) res.append(c);
      if (c == '(') level++;
    }
    return res.toString();
  }

  public static void main(String[] args) {

  }
}
